package com.cskaoyan.gateway.controller.user;

import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;
import com.mall.user.IVerifyUserService;
import com.mall.user.annotation.Anoymous;
import com.mall.user.constants.SysRetCodeConstants;
import com.mall.user.dto.UserVerifyRequest;
import com.mall.user.dto.UserVerifyResponse;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("user")
public class VerifyUserController {

    @Reference(timeout = 3000 ,check = false)
    IVerifyUserService verifyUserService;

    @GetMapping("verify")
    @Anoymous
    public ResponseData verify(String uid, String username){
        UserVerifyRequest request = new UserVerifyRequest(username,uid);
        UserVerifyResponse response = verifyUserService.verifyUser(request);
        if (!response.getCode().equals(SysRetCodeConstants.SUCCESS.getCode())){
            return new ResponseUtil().setErrorMsg(response.getMsg());
        }
        return new ResponseUtil().setData(null);
    }
}
